/**
 *******************************************************************************
 * @FileName  : byte_stream.c
 * @Author    : GaoQiu
 * @CreateDate: 2020-05-18
 * @Copyright : Copyright(C) GaoQiu
 *              All Rights Reserved.
 *******************************************************************************
 *
 * The information contained herein is confidential and proprietary property of
 * GaoQiu and is available under the terms of Commercial License Agreement
 * between GaoQiu and the licensee in separate contract or the terms described
 * here-in.
 *
 * This heading MUST NOT be removed from this file.
 *
 * Licensees are granted free, non-transferable use of the information in this
 * file under Mutual Non-Disclosure Agreement. NO WARRENTY of ANY KIND is provided.
 *
 *******************************************************************************
 */
#include "byte_stream.h"
#include "defs_types.h"

void Uint64ToBstream(uint8_t *p, uint64_t n)
{
	p[0] = (uint8_t)(n >>  0);
	p[1] = (uint8_t)(n >>  8);
	p[2] = (uint8_t)(n >> 16);
	p[3] = (uint8_t)(n >> 24);
	p[4] = (uint8_t)(n >> 32);
	p[5] = (uint8_t)(n >> 40);
	p[6] = (uint8_t)(n >> 48);
	p[7] = (uint8_t)(n >> 56);
}

uint64_t BstreamToUint64(uint8_t *p)
{
	return  ((uint64_t)p[0] <<  0) |
			((uint64_t)p[1] <<  8) |
			((uint64_t)p[2] << 16) |
			((uint64_t)p[3] << 24) |
			((uint64_t)p[4] << 32) |
			((uint64_t)p[5] << 40) |
			((uint64_t)p[6] << 48) |
			((uint64_t)p[7] << 56);
}
